<?php
// +----------------------------------------------------------------------
// | Tpli [ WE ONLY DO WHAT IS NECESSARY ]
// +----------------------------------------------------------------------
// | Author 荒年 < 931274989@qq.com >
// +----------------------------------------------------------------------
// | Explain 验证基类
// +----------------------------------------------------------------------
namespace app\base\validate;

use think\Validate;
use Exception;

class BaseValidate extends Validate
{
  public function goCheck()
  {
    $result = $this->check(request()->param());
    if (!$result)
    {
      $controller = new ControllerValidate();
      $controller->vailErr($this->error);
    }
    else
    {
      return true;
    }
  }

  //空值验证
  protected function isNotEmpty($value,$rule='',$data='',$field='')
  {
    if (empty($value)) {
      return false;
    } else {
      return true;
    }
  }

  //手机号验证
  protected function isMobile($value)
  {
    $rule = '^1(3|4|5|7|8)[0-9]\d{8}$^';
    $result = preg_match($rule,$value);
    if ($result) {
      return true;
    }else{
      return false;
    }
  }

}
?>